<link rel="stylesheet" type="text/css" href="<?php echo TEMPLATES_PATH; ?>/css/index.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo TEMPLATES_PATH; ?>/css/official_shop.css">
<style>
    .good-img_m{width:100%; }
    .ycyc{ overflow:hidden; word-break:normal; word-break:break-all; display:block; font-size:12px; height:30px; max-height:35px !important}
    .new-tbl-cell p{margin-bottom:0;line-height: 20px;}
    .bg-white{margin-top: 5px;}
    .button-small:hover{background-color: #e62d93 !important;}
    .button-small:hover a{color: #fff;}
    .button-small{background-color: #fdc;}
    .button-small a{color: #e62d93;}
    .me-font{color:red;font-size: 18px}
</style>
<header class="layout head padding-small">
    <a href="javascript:pageBack();" class="hBack float-left"></a>
    <h4 class="hTxt float-left text-center text-white">精品超市</h4>
    <a href="javascript:;" id="btnJdkey" class="hHlep float-right"></a>
</header>
<script type="text/javascript">
	$(function(){
		$(window).scroll(function(){
			var $header = $('header');
			if($(window).scrollTop() >= 44){
				$header.hide();
			}else{
				$header.show();
			};
		});
	})
</script>
<div class="layout padding fixed">
    <div class="layout " >

        <div class="line">
            <ul class="x12 list-unstyle">
                <form method="get">
                    <input type="hidden" name="act" value="official_shop" />
                    <li class="x9"><input type="text" name="keyword" value="<?php echo
                        $_GET['keyword']?>" class="input left_yj" placeholder="输入商品名称"></li>
                    <li class="x3"><input type="submit" class="button right_yj bg-dot button-block" value="搜 索"/></li>
                </form>
            </ul>
        </div><!--//line-->
    </div>
</div>
<div>
    <?php if (!empty($output['adv']) && is_array($output['adv'])) { ?>
        <div  style="display:none" class="banner scroll-wrapper" id="idContainer2" data-num="<?php echo count($output['adv']); ?>">
            <ul class="scroller" style="position:relative;left:0px;width:<?php echo count($output['adv']); ?>00%"
                id="idSlider2">
                <?php foreach ($output['adv'] as $item) {
                    $content = unserialize($item['adv_content']);
                    ?>
                    <li style="width:-100.0%">
                        <a href='<?php echo replace_link($content['adv_slide_url']); ?>'><img
                                src="<?php echo SiteUrl . "/" . ATTACH_ADV . "/" . $content['adv_slide_pic'] ?>"
                                alt="<?php echo $item['adv_title'] ?>"/></a>
                    </li>
                <?php } ?>
            </ul>
            <ul class="new-banner-num new-tbl-type" id="idNum"></ul>
        </div>
    <?php } ?>
    <div class="content">
        <div class="left">
            <?php if (is_array($output['store_class']) && !empty($output['store_class'])) { ?>
                <div class="module_sidebar">
                    <!--<h2><b>商品分类</b></h2>-->
                    <div class="wrap">
                        <div class="side_category">
                        	<h2><b>美发系列</b></h2>
                            <!--<h4 align="center">美发系列</h4>-->
                            <?php $i=0; foreach ($output['store_class'] as $k => $v) { $i++;?>
                                <dl>
                                    <dt>
                                        <a href="index.php?act=official_shop&class_id=<?php echo $k; ?>" <?php if ($_GET['class_id'] == $k) {
                                            echo 'style="color:red;"';
                                        } ?>><?php echo $v['stc_name']; ?></a></dt>
                                    <?php if (is_array($v['children']) && count($v['children']) > 0) {
                                        foreach ($v['children'] as $v1) {
                                            ?>
                                            <dd>&nbsp;&nbsp;<a
                                                    href="index.php?act=official_shop&class_id=<?php echo $v1['stc_id']; ?>" <?php if ($_GET['class_id'] == $v1['stc_id']) {
                                                    echo 'style="color:red;"';
                                                } ?>
                                                    title="<?php echo $v1['stc_name']; ?>"><?php echo $v1['stc_name']; ?></a>
                                            </dd>
                                        <?php }
                                    } ?>
                                </dl>
                            <?php if($i>3)break;} ?>
                            <dl>
                                <dt><a href="index.php?act=official_shop&op=list&class=keycomment">系列产品</a></dt>
                            </dl>
                            <h2><b>美容系列</b></h2>
                            <!--<h4 align="center" >美容系列</h4>-->
                            <?php $i=0; foreach ($output['store_class'] as $k => $v) { $i++;if($i<=4)continue;?>
                                <dl>
                                    <dt>
                                        <a href="index.php?act=official_shop&class_id=<?php echo $k; ?>" <?php if ($_GET['class_id'] == $k) {
                                            echo 'style="color:red;"';
                                        } ?>><?php echo $v['stc_name']; ?></a></dt>
                                    <?php if (is_array($v['children']) && count($v['children']) > 0) {
                                        foreach ($v['children'] as $v1) {
                                            ?>
                                            <dd>&nbsp;&nbsp;<a
                                                    href="index.php?act=official_shop&class_id=<?php echo $v1['stc_id']; ?>" <?php if ($_GET['class_id'] == $v1['stc_id']) {
                                                    echo 'style="color:red;"';
                                                } ?>
                                                    title="<?php echo $v1['stc_name']; ?>"><?php echo $v1['stc_name']; ?></a>
                                            </dd>
                                        <?php }
                                    } ?>
                                </dl>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
            <?php } ?>
            <div class="shuaixuan">分类筛选</div>
        </div>
        <div class="right">
            <div class="layout"><img class="layout" src="<?php echo TEMPLATES_PATH; ?>/images2/jpcs.jpg"></div>
            <!--排序方式 S-->
            <a name="jpcs_order"></a>
            <div class="radius-big bg-white margin padding clearfix text-center" id="official-goods-tab">
                <a href="javascript:void(0);" class="x20 text-red" onclick="changeOrder(this)" data-tp="default">默认</a>
                <a href="javascript:void(0);" class="x20  <?php if($_GET['key']=='sales'){echo 'text-red';}?>" onclick="changeOrder(this)" data-tp="sales">销量 <i class="<?php echo $_GET['key']=='sales' && $_GET['order']=='desc'? "icon-long-arrow-up" : ($_GET['key']=='sales' && $_GET['order']=='asc'? 'icon-long-arrow-down': '');?>"></i></a>
                <a href="javascript:void(0);" class="x20 <?php if($_GET['key']=='price'){echo 'text-red';}?>" onclick="changeOrder(this)" data-tp="price">价格 <i class="<?php echo $_GET['key']=='price' && $_GET['order']=='desc'?"icon-long-arrow-up" : ($_GET['key']=='price' && $_GET['order']=='asc'?'icon-long-arrow-down':'');?>"></i></a>
                <a href="javascript:void(0);" class="x20 <?php if($_GET['key']=='click'){echo 'text-red';}?>" onclick="changeOrder(this)" data-tp="click">人气 <i class="<?php echo $_GET['key']=='click' && $_GET['order']=='desc'?"icon-long-arrow-up" : ($_GET['key']=='click' && $_GET['order']=='asc'?'icon-long-arrow-down':'');?>"></i></a>
                <form id="condtion" method="get">
                    <input type="hidden" name="act" value="official_shop" />
                    <input name="class_id" value="<?php echo (int)$_GET['class_id']?>" type="hidden">
                    <input name="key" value="<?php echo $_GET['key'];?>" type="hidden" />
                    <input name="order" value="<?php echo $_GET['order'];?>" type="hidden" />
                </form>
            </div>
            <script>
                function changeOrder(obj){
                    var key = $('input[name=key]');
                    var order = $('input[name=order]');
                    if($(obj).data('tp') == key.val()){
                        if($(obj).data('tp') == 'default'){
                            order.val('');
                        }else if(order.val() == 'desc'){
                            order.val('asc');
                        }else {
                            order.val('desc');
                        }
                    }else{
                        key.val($(obj).data('tp'));

                        if($(obj).data('tp') == 'default'){
                            order.val('');
                        }else{
                            order.val('desc');
                        }
                    }
                    $('#condtion').submit();
                }
                <?php if(isset($_GET['key']) && $_GET['key']!=='default'){?>
                $('#official-goods-tab a:first').removeClass('text-red');
                <?php }?>
                //如果点击排序，页面跳转到指定位置
                <?php if(isset($_GET['key']) || isset($_GET['class_id'])){?>
                $(function(){
                    var str_url = window.location.href;
                    if(str_url.indexOf("#jpcs_order")==-1){
                        str_url = str_url+"#jpcs_order";
                        window.location.href = str_url;
                    }
                })
                <?php }?>
            </script>
            <!--排序E-->
            <div class="tilte bg-white">
                <h4 class="text-white"><em><?php echo $output['class']['stc_name']?$output['class']['stc_name']:'精品系列';?></em></h4>
            </div>

            <div class="container-layout bg padding-top">

                <div class="line-small">
            <!--属性筛选 Start-->
            <?php $dl = 1; //dl标记?>
            <?php if (!empty($output['attr_array']) && is_array($output['attr_array'])) { ?>

                <div class="module_filter">
                    <div class="module_filter_line">

                        <?php if (isset($output['checked_attr']) && is_array($output['checked_attr'])) { ?>
                            <dl class="module_filter_nav" nc_type="ul_filter">
                                <dt><?php echo '已选：'; ?></dt>
                                <?php foreach ($output['checked_attr'] as $val) { ?>
                                    <dd class="normal" nc_type="dd_filter" style="cursor:pointer"><span
                                            class="nc-txt"><?php echo $val['attr_name'] . ':<i>' . $val['attr_value'] . '</i>' ?></span><span
                                            class="ico"><img title="" alt="a_id"
                                                             kid="<?php echo $val['attr_value_id']; ?>"
                                                             src="<?php echo TEMPLATES_PATH; ?>/images/delete.gif"></span>
                                    </dd>
                                <?php } ?>
                            </dl>
                        <?php } ?>
                        <?php if (!empty($output['attr_array']) && is_array($output['attr_array'])) { ?>
                            <?php $j = 0;
                            foreach ($output['attr_array'] as $key => $val) {
                                $j++; ?>
                                <?php if (!isset($output['checked_attr'][$key]) && !empty($val['attr_values']) && is_array($val['attr_values'])) { ?>
                                    <dl <?php if ($dl >1){ ?>class="dl_hide"<?php } ?>
                                        <?php if (count($output['attr_array']) == $j){ ?>style="border:none;"<?php } ?>>
                                        <dt><?php echo $val['attr_name'] . '：'; ?></dt>
                                        <dd class="list">
                                            <ul>
                                                <?php $i = 0;
                                                foreach ($val['attr_values'] as $k => $v) {
                                                    $i++ ?>
                                                    <li <?php if ($i > 10){ ?>style="display:none"
                                                        nc_type="none"<?php } ?>><a
                                                            href="javascript:replaceParam('a_id','<?php echo $_GET['a_id'] != '' ? $_GET['a_id'] . ',' . $v['attr_value_id'] : $v['attr_value_id']; ?>');"><?php echo $v['attr_value']; ?></a><!-- em>(<?php echo $v['count'] ?>)</em -->
                                                    </li>
                                                <?php } ?>
                                            </ul>
                                        </dd>
                                    </dl>
                                <?php } ?>
                                <?php $dl++;
                            } ?>
                        <?php } ?>
                    </div>
                    <div class="bottom">
                        <div class="side">
                            <div class="btn" nc_type="show"><span
                                    class="btn1"><i></i>点击折叠收起</span></div>
                        </div>
                    </div>
                </div>
            <?php } ?>

            <!--属性筛选 End-->

            <!-- 供应商筛选开始 -->
            <?php if(!empty($output['su_select']) && is_array($output['su_select'])){?>
                <div class="module_filter">
                    <div class="module_filter_line">
                        <dl>
                            <dt>供应商：</dt>
                            <dd class="list">
                                <ul>
                                    <?php foreach ($output['su_select'] as $_k => $_v) {?>
                                        <li><a href="javascript:replaceParam('supplier_id','<?php echo $_v['supplier_id'];?>');"><?php echo $_v['supplier_name'];?></a></li>
                                    <?php }?>
                                </ul>
                            </dd>
                        </dl>
                    </div>
                    <div class="bottom"></div>
                </div>
            <?php }?>
            <!-- 供应商筛选结束 -->


            <!-- 商品关键字推荐筛选开始 -->
            <?php if(!empty($output['kg_select']) && is_array($output['kg_select'])){?>
                <div class="module_filter">
                    <div class="module_filter_line">
                        <dl>
                            <dt>商品推荐：</dt>
                            <dd class="list">
                                <ul>
                                    <?php foreach ($output['kg_select'] as $_k => $_v) {?>
                                        <li><a href="javascript:replaceParam('goods_keywords_commend','<?php echo $_v['goods_keywords_commend'];?>');"><?php echo $_v['goods_keywords_commend'];?></a></li>
                                    <?php }?>
                                </ul>
                            </dd>
                        </dl>
                    </div>
                    <div class="bottom"></div>
                </div>
            <?php }?>
            <!-- 商品关键字推荐筛选结束 -->
            <!--商品列表改版 S-->
                    <?php if(!empty($output['goods_all']) && is_array($output['goods_all'])){
                        foreach($output['goods_all'] as $goods){?>

                            <div class="x6 margin-small-top ">
                                <ul class="list-unstyle padding-small radius-big bg-white clearfix ">
                                    <li><a href="<?php echo ncUrl(array('act'=>'goods','goods_id'=>$goods['goods_id']),'goods',$goods['store_domain']);?>"><img class="img-responsive self-motion" src="<?php echo thumb($goods,'small');?>" onerror="this.src='<?php echo TEMPLATES_PATH.'/images/touch2013/no_140_140.jpg'?>'" onload="imgheqw(this)"></a></li>
                                    <li class="ycyc"><a href="<?php echo ncUrl(array('act'=>'goods','goods_id'=>$goods['goods_id']),'goods',$goods['store_domain']);?>"><?php echo preg_replace('@script.*?script@si', '', $goods['goods_name']);?></a></li>
                                    <li class="text-small zt-color">美财价：<?php if ($_SESSION['is_login'] == '1') {
                                            if($goods['group_flag']==0 && $goods['xianshi_flag']==0){
                                                echo $goods['goods_store_price'];
                                            }else if($goods['group_flag']==1 && $goods['xianshi_flag']==0){
                                                echo $goods['group_price'];
                                            }else if($goods['group_flag']==0 && $goods['xianshi_flag']==1){
                                                echo ncPriceFormat($goods['goods_store_price']*($goods['xianshi_discount']/10));
                                            }else if($goods['group_flag']==1 && $goods['xianshi_flag']==1){
                                                if($goods['group_price'] < ($goods['goods_store_price']*($goods['xianshi_discount']/10))){
                                                    echo $goods['group_price'];
                                                }else{
                                                    echo  ncPriceFormat($goods['goods_store_price']*($goods['xianshi_discount']/10));
                                                }
                                            }
                                        } else {
                                            echo '<a href="index.php?act=login">请登录</a>';
                                        } ?></li>
                                    <li class="button-small button border-red-light radius-rounded float-right"><a href="<?php echo ncUrl(array('act'=>'goods','goods_id'=>$goods['goods_id']),'goods',$goods['store_domain']);?>">立即抢购</a></li>
                                </ul>
                            </div>
                        <?php }
                    }else{
                        echo "<p style='text-align:center;color:red;'>暂无数据</p>";
                    }?>

                </div>
            </div>
            <!--商品列表改版 E-->
            <div class="clear"></div>
        </div>

    </div>
    <script type="text/javascript" src="<?php echo RESOURCE_PATH; ?>/js/waypoints.js"></script>
    <script type="text/javascript">
        var defaultSmallGoodsImage = '<?php echo defaultGoodsImage('small');?>';
        var defaultTinyGoodsImage = '<?php echo defaultGoodsImage('tiny');?>';
        //浮动导航  waypoints.js
        $('#main-nav-holder').waypoint(function (event, direction) {
            $(this).parent().toggleClass('sticky', direction === "down");
            event.stopPropagation();
        });

        <?php if($_GET['a_id'] == ''){?>
        $(this).children().addClass('btn2').removeClass('btn1');
        $('.dl_hide').hide();
        $('.dl_hide:first').prev().css('border', 'none');
        $('div[nc_type="show"] > span').html('点击展开全部');
        <?php }?>

        // 总的 显示更多
        $('div[nc_type="show"]').click(function () {
            if ($('.dl_hide').css('display') == 'none') {
                $('.dl_hide').show();
                $('div[nc_type="show"] > span').html('点击收起');
                $('.dl_hide:first').prev().css('border', '');
            } else {
                $('.dl_hide').hide();
                $('div[nc_type="show"] > span').html('点击展开全部');
                $('.dl_hide:first').prev().css('border', 'none');
            }
        });

        // 单行显示更多
        $('span[nc_type="show"]').click(function () {
            s = $(this).parents('dd').prev().find('li[nc_type="none"]');
            if (s.css('display') == 'none') {
                $(this).addClass('btn2').removeClass('btn1');
                s.show();
                $(this).html('收起');
            } else {
                $(this).addClass('btn1').removeClass('btn2');
                s.hide();
                $(this).html('更多');
            }
        });
    </script>
    <div class="clear"></div>
    <?php require_once 'page.php';?>
</div>
<!--<div id="search_fixed">
    <div id="ser_div_pos">
        <form method="get">
            <input type="hidden" name="act" value="official_shop"/>
            <input type="text" name="keyword" id="keyword" value=""/>
            <input type="submit" id="sub_search" value="搜  索"/>
        </form>
    </div>
</div>-->

<script type="text/javascript">
    var SITE_URL = window.location.toString().split('/index.php')[0];
    SITE_URL = SITE_URL.replace(/(\/+)$/g, '');
    function transform_char(str)
    {
        if(str.indexOf('&'))
        {
            str = str.replace(/&/g, "%26");
        }
        return str;
    }
    $(function(){
        //商品名称过长时的处理
        deal_words($('.ycyc a'));

        //path
        $(".shuaixuan").click(function(){
            if($('.content .left').css("left")=="-253px"){
                $('.content .left').animate({left:"0px"},{speed:300});
            }else{
                $('.content .left').animate({left:"-253px"},{speed:300});
            }
            /* var span = $(this).find("span");
             if(span.attr("class") == "open"){

             span.removeClass("open");
             span.addClass("close");
             $(".plug-btn").removeClass("open");
             $(".plug-btn").addClass("close");
             }else{
             span.removeClass("close");
             span.addClass("open");
             $(".plug-btn").removeClass("close");
             $(".plug-btn").addClass("open");
             }*/
        });
        //$(".plug-menu").on('touchmove',function(event){event.preventDefault();});
    });

    /*var c_startX,c_startY,c_endX,c_endY;
     var c_main = window.document.getElementById('c_main');
     c_main.addEventListener('touchstart',function(event){
     //event.touches[0].screenX
     c_startX = event.touches[0].clientX;
     c_startY = event.touches[0].clientY;
     },false)
     c_main.addEventListener('touchmove',function(event){
     //event.touches[0].screenX
     c_endX = event.touches[0].clientX;
     c_endY = event.touches[0].clientY;
     },false)
     c_main.addEventListener('touchend',function(event){
     if((c_endY - c_startY) < 0){
     $('#search_fixed').hide();
     }else{
     $('#search_fixed').show();
     }
     },false)*/

    <?php if(!empty($output['adv']) && is_array($output['adv'])){?>
    //广告轮播图
    var picCount = $("#idContainer2").data('num');
    $(".pic-num1").css("width", (picCount * 30) + "px");
    var forEach = function (array, callback) {
        for (var i = 0, len = array.length; i < len; i++) {
            callback.call(this, array[i], i);
        }
    }
    var st = createPicMove("idContainer2", "idSlider2", picCount);	//图片数量更改后需更改此数值
    var nums = [];
    //插入数字
    for (var i = 0, n = st._count - 1; i <= n; i++) {
        var li = document.createElement("li");
        nums[i] = document.getElementById("idNum").appendChild(li);
    }
    //设置按钮样式
    st.onStart = function () {
        //forEach(nums, function(o, i){ o.className = ""})
        forEach(nums, function (o, i) {
            o.className = st.Index == i ? "new-tbl-cell on" : "new-tbl-cell";
        })
    }
    // 重新设置浮动
    $("#idSlider2").css("position", "relative");
    var banSlide = window.document.getElementById('idContainer2');
    var _initX = 0;
    var _finishX = 0;
    var _startX = 0;
    var _startY = 0;
    banSlide.addEventListener('touchstart', function (event) {
        _startX = event.touches[0].clientX;
        _startY = event.touches[0].clientY;
        _initX = _startX;
    }, false)
    banSlide.addEventListener('touchmove', function (event) {
        var touches = event.touches;
        var _endX = event.touches[0].clientX;
        var _endY = event.touches[0].clientY;
        if (Math.abs(_endY - _startY) > Math.abs(_endX - _startX)) {
            return;
        }
        event.preventDefault();
        _finishX = _endX;
        var _absX = Math.abs(_endX - _startX);
        var lastX = $('#idSlider2').css('left').replace('px', '');
        if (_startX > _endX) {
            st.Stop();
            $('#idSlider2').css('left', (parseInt(lastX) - _absX) + 'px');
        } else {
            st.Stop();
            $('#idSlider2').css('left', (parseInt(lastX) + _absX) + 'px');
        }
        _startX = _endX;
    }, false)
    //触屏  离开屏幕事件
    banSlide.addEventListener('touchend', function (event) {
        if (_finishX == 0) {
            return;
        }
        if (_initX > _finishX) {
            bindEvent(_initX, _finishX);
        } else if (_initX < _finishX) {
            bindEvent(_initX, _finishX);
        }
        _initX = 0;
        _finishX = 0;
    }, false)

    /**
     *  绑定触屏触发事件
     * @param start
     * @param end
     */
    function bindEvent(start, end) {
        if (start >= end) {
            st.Next();
        } else {
            st.Previous();
        }
    }
    st.Run();
    var resetScrollEle = function () {
        $("#shelper").css("width", $("#newkeyword").width() + "px");
        var slider2Li = $("#idSlider2 li");
        slider2Li.css("width", $(".scroll-wrapper").width() + "px");
    }
    //重载
    window.addEventListener("resize", function () {
        st.Change = st._slider.offsetWidth / st._count;
        st.Next();
        resetScrollEle();
    });
    //屏幕旋转事件
    window.addEventListener("orientationchange", function () {
        st.Change = st._slider.offsetWidth / st._count;
        st.Next();
        resetScrollEle();
    })
    resetScrollEle();
    <?php }?>
</script>
<script type="text/javascript" src="<?php echo RESOURCE_PATH . '/js/official_shop_list.js'; ?>"charset="utf-8"></script>